﻿@model PagedList<ADZ_JingjiaMaster>
@{
    ViewBag.Title = "竞价列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    JingjiaQueryModel paramModel = new JingjiaQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (JingjiaQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("getlist", "jingjia")" method="get">
    <div class="form_query">
        <div>
            竞价配置：
            <select id="jingjia_config_id" name="jingjia_config_id">
                <option value="-10">全部</option>
                @{
                    var config_list = (from t in dbcontext.ADZ_JingjiaConfig.Where(t => t.is_del == 0)
                                       select new
                                       {
                                           t.jingjia_config_id,
                                           t.jingjia_config_name
                                       }).ToList();
                    dc = new Dictionary<string, string>();
                    if (config_list.Any())
                    {
                        config_list.ForEach(t =>
                        {
                            dc.Add(t.jingjia_config_id.ToString(), t.jingjia_config_name);
                        });
                    }
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.jingjia_config_id.ToString());
            </select>&nbsp;

        </div>
        <div>
            竞价包名称：
            <input type="text" name="jingjia_name" id="jingjia_name" class="abc input-default" placeholder="" value="@paramModel.jingjia_name">&nbsp;
        </div>
        <div>
            竞价状态：
            <select id="jingjia_satus" name="jingjia_satus">
                <option value="-10">全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    dc.Add("0", "未开始");
                    dc.Add("1", "竞价中");
                    dc.Add("2", "已结束");
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.jingjia_satus.ToString());
            </select>&nbsp;

        </div>
        <div>
            &nbsp;&nbsp;&nbsp;<input style="vertical-align:top" type="checkbox" name="is_notpay" id="is_notpay" value="1" checked />成交未付款    &nbsp;&nbsp;&nbsp;
        </div>
        <div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
            <button type="button" class="btn btn-success" id="btnadd" onclick="document.location='@Url.Action("add","jingjia")'">新增竞价包</button>

            &nbsp;&nbsp;<button type="button" backpageid="jingjia/getconfiglist" class="btn btn-success" name="backid" id="backid">返回竞价配置</button>

        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>编号</th>
            <th style="text-align:center;vertical-align:middle;">竞价图片</th>
            <th>竞价包名称</th>
            <th>竞价状态</th>
            <th>是否含税</th>
            <th>起拍价</th>
            <th>加价幅度</th>
            <th>留置价</th>
            <th>延时周期</th>
            <th>拍卖类型</th>
            <th>结束时间</th>
            <th>出价次数</th>
            <th>围观次数</th>
            <th>最后出价时间</th>
            <th>最后出价金额</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
            <tr class="@HtmlPagerHelper.TrClass(index)">
                <td>@m.jingjia_id</td>
                <td style="text-align:center;vertical-align:middle;"><img src="@ImageFileBiz.GetImg(m.img_url,"small")" class="height20" /></td>
                <td>@m.jingjia_name</td>
                <td>
                    @if (m.jingjia_satus == 0)
                    {
                        <info>未开始</info>
                    }
                    else if (m.jingjia_satus == 1)
                    {
                        <info class="orange">竞价中</info>
                    }
                    else if (m.jingjia_satus == 2)
                    {
                        if (m.jingjia_deal_status == 2)
                        {
                            <info class="green">已成交</info>
                            var jingjiaSubmit = dbcontext.ADZ_JingjiaSubmit.FirstOrDefault(t => t.jingjia_id == m.jingjia_id && t.is_hit == 1);
                            if (jingjiaSubmit != null)
                            {
                                if (jingjiaSubmit.status == 2)
                                {
                                    <info class="red">未付款 <a href="/OrderMaster/OrderMasterInfo/@jingjiaSubmit.order_master_id">查看订单</a></info>
                                }
                                if (jingjiaSubmit.status == 10)
                                {
                                    <info class="green">已付款 <a href="/OrderMaster/OrderMasterInfo/@jingjiaSubmit.order_master_id">查看订单</a></info>
                                }
                            }
                        }
                        else
                        {
                            <info class="red">已流拍</info>
                        }
                    }
                </td>
                <td>
                    @if (m.include_tax == 1)
                    {
                        <info class="green">含税</info>
                    }
                    else
                    {
                        <info class="">未含税</info>
                    }
                </td>
                <td>@m.base_price.ToString("N2")</td>
                <td>
                    @m.step_price.ToString("N2")
                    @if (m.step_price_max > 0)
                    {
                        <info> - @m.step_price_max.ToString("N2")</info>
                    }
                </td>
                <td>
                    @if (@m.liuzhi_price > 0)
                    {
                        <info>@m.liuzhi_price.ToString("N2")</info>
                    }
                </td>
                <td>@m.stay_miniutes 分钟/次</td>
                <td>@m.jingjia_type</td>
                <td>@m.real_end_time.ToString(1)</td>
                <td>
                    @m.chujia_counts
                    <a href="/jingjia/ChujiaGetList?jingjia_id=@m.jingjia_id">查看</a>
                </td>
                <td>@m.weiguan_counts</td>
                <td>@m.last_time.ToString(1)</td>
                <td>@m.last_price.ToString("N2")</td>
                <td>
                    <a href="@Url.Action("add", "jingjia", new { id = m.jingjia_id})">编辑</a>
                    <a href="javascript:void(0);" onclick="toDel(@m.jingjia_id)">删除</a>
                </td>
            </tr>
        }
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>


<script>


    BUI.use('bui/overlay', function (overlay) {
        $(function () {
            switch ('@paramModel.is_notpay') {
                case '0':
                    $("input[name='is_notpay']").get(0).checked = false;
                    break;
                default:
                    $("input[name='is_notpay']").get(0).checked = true;
                    break;
            }
        });
    });
    reloadHandler = function () {
        window.location.reload();
    }

    function toDel(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要删除此竞价吗?',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("ToDel", "jingjia")";
                                parameter = { id: id };
                      $.post(url, parameter, function (result) {
                                    ShowActionResult(result, reloadHandler);
                                });
                                this.close();
                            }
                        },
              {
                            text: '取消',
                  elCls: 'button',
                  handler: function () {
                                this.close();
                            }
              }

            ]
        });
    }
</script>